package com.chen.springboot.controller;

import com.mysql.cj.util.StringUtils;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

public class IndexController {
    @RequestMapping("/user/login")
    public String login(
            @RequestParam("username") String username,
            @RequestParam("password") String password, Model model){
        //具体业务
        if (!StringUtils.isNullOrEmpty(username) && "123456".equals(password)){
            return "dashboard";
        }else {
            //告诉用户已经登录失败
            model.addAttribute("msg","用户名或密码错误");
            return "index";
        }
    }
}
